#ifndef log_Helper_Marco_h
#define log_Helper_Marco_h

#include "Manager.h"
#include "HelperFunctions.h"
#include <utility/String.h>
#include <log4cplus/logger.h>

//#define DECLARE_LOG() \
//	private: \
//		static log4cplus::Logger* sLogger;
//
//#define IMPLEMENT_LOG(className, name) \
//	log4cplus::Logger* className::sLogger = &log4cplus::Logger::getInstance(LOG4CPLUS_TEXT(name));

#define LogTraceName(name, msg) \
	do \
		{ \
		serika::ut::String logMsg = serika::log::AddFunctionName(FUNCTION_NAME, msg); \
		log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
		LOG4CPLUS_TRACE_STR(logger, logMsg); \
	} while(0)

#define LogDebugName(name, msg) \
	do \
		{ \
		serika::ut::String logMsg = serika::log::AddFunctionName(FUNCTION_NAME, msg); \
		log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
		LOG4CPLUS_DEBUG_STR(logger, logMsg); \
	} while(0)

#define LogInfoName(name, msg) \
	do \
		{ \
		serika::ut::String logMsg = serika::log::AddFunctionName(FUNCTION_NAME, msg); \
		log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
		LOG4CPLUS_INFO_STR(logger, logMsg); \
	} while(0)

#define LogWarnName(name, msg) \
	do \
		{ \
		serika::ut::String logMsg = serika::log::AddFunctionName(FUNCTION_NAME, msg); \
		log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
		LOG4CPLUS_WARN_STR(logger, logMsg); \
	} while(0)

#define LogErrorName(name, msg) \
	do \
		{ \
		serika::ut::String logMsg = serika::log::AddFunctionName(FUNCTION_NAME, msg); \
		log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
		LOG4CPLUS_ERROR_STR(logger, logMsg); \
	} while(0)

#define LogFatalName(name, msg) \
	do \
		{ \
		serika::ut::String logMsg = serika::log::AddFunctionName(FUNCTION_NAME, msg); \
		log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
		LOG4CPLUS_FATAL_STR(logger, logMsg); \
	} while(0)

#define  TraceMethodName(name) \
	serika::ut::String logMsg = serika::log::GetFunctionName(FUNCTION_NAME); \
	log4cplus::Logger& logger = serika::log::Manager::GetLogger(_T(name)); \
	LOG4CPLUS_TRACE_METHOD(logger, logMsg);

#define LogTrace(msg) \
	LogTraceName("", msg)

#define LogDebug(msg) \
	LogDebugName("", msg)

#define LogInfo(msg) \
	LogInfoName("", msg)

#define LogWarn(msg) \
	LogWarnName("", msg)

#define LogError(msg) \
	LogErrorName("", msg)

#define LogFatal(msg) \
	LogFatalName("", msg)

#define TraceMethod() \
	TraceMethodName("")

#ifdef WIN32
#define FUNCTION_NAME _T(__FUNCTION__)
#else
#define FUNCTION_NAME _T(__PRETTY_FUNCTION__)
#endif 

#define ToLogString(x) \
	serika::log::ToString(_T(#x), (x))

//#ifdef WIN32
//#define ADD_FUNCTION_NAME(msg) \
//	ss << FUNCTION_NAME << "(): " << msg;
//#else
//#define ADD_FUNCTION_NAME(msg) \
//	ss << FUNCTION_NAME << ": " << msg;
//#endif

#endif
